﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TiposComuns.Objectos;

namespace Servidor.Objectos
{
    /// <summary>
    /// Requesting a new friendship relation
    /// </summary>
    [Serializable]
    public class RequestFriendAction : Action
    {
        #region Attributes
        private Person target;          //New potential friend
        #endregion

        #region Constructors
        public Person Target
        {
            get { return target; }
            set { target = value.Clone(); }
        }

        public RequestFriendAction() { }

        public RequestFriendAction(IDMsg id, Person target)
            : base(id)
        {
            this.target = target;
        }
        #endregion

        #region Methods
        public override void Execute(User user)
        {
            user.RequestFriend(target);
        }

        public override void RollBack(User user)
        {
            user.Friends.Sent.Remove(this.target.Username);
        }

        #endregion
    }
}
